Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ENH: Give more informative file format errors #1165

Merged
merged 1 commit into from
Feb 14, 2024

Conversation

mferrera
Copy link
Collaborator

Resolves #706

This will list some potential file formats, which are not complete in their file extensions permutations but should be sufficient enough to give a hint as to what kind of required.

@mferrera mferrera self-assigned this Feb 14, 2024
@@ -491,7 +494,7 @@ def _format_from_contents(self) -> FileFormat:
self.file.seek(mark)
else:
if not self.exists():
raise ValueError(f"File {self.name} does not exist")
raise FileNotFoundError(f"File {self.name} does not exist")
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bonus exception type change

@codecov-commenter
Copy link

codecov-commenter commented Feb 14, 2024

Codecov Report

Attention: 14 lines in your changes are missing coverage. Please review.

Comparison is base (33652a2) 80.08% compared to head (b51d79e) 80.06%.

Files Patch % Lines
src/xtgeo/well/_well_aux.py 25.00% 2 Missing and 1 partial ⚠️
src/xtgeo/grid3d/_grid_import.py 60.00% 2 Missing ⚠️
src/xtgeo/grid3d/grid_property.py 33.33% 2 Missing ⚠️
src/xtgeo/surface/regular_surface.py 33.33% 2 Missing ⚠️
src/xtgeo/xyz/points.py 33.33% 2 Missing ⚠️
src/xtgeo/xyz/polygons.py 33.33% 2 Missing ⚠️
src/xtgeo/io/_file.py 85.71% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1165      +/-   ##
==========================================
- Coverage   80.08%   80.06%   -0.02%     
==========================================
  Files          97       97              
  Lines       13612    13634      +22     
  Branches     2186     2187       +1     
==========================================
+ Hits        10901    10916      +15     
- Misses       1981     1988       +7     
  Partials      730      730              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@mferrera mferrera force-pushed the improve-data-reader-error branch from 0773769 to 844e3c6 Compare February 14, 2024 09:24
@mferrera mferrera marked this pull request as ready for review February 14, 2024 09:27
Copy link
Collaborator

@jcrivenaes jcrivenaes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See comments, otherwise 👍

@mferrera mferrera force-pushed the improve-data-reader-error branch from 844e3c6 to 335dbff Compare February 14, 2024 10:48
This will list some potential file formats, which are not complete in
their file extensions permutations but should be sufficient enough to
give a hint as to what kind of required.
@mferrera mferrera force-pushed the improve-data-reader-error branch from 335dbff to b51d79e Compare February 14, 2024 10:53
Comment on lines +55 to +64
[
FileFormat.ROFF_BINARY,
FileFormat.ROFF_ASCII,
FileFormat.EGRID,
FileFormat.FEGRID,
FileFormat.GRDECL,
FileFormat.BGRDECL,
FileFormat.XTG,
FileFormat.HDF,
]
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ideally in #1164 this list becomes a property of the different class types, or something like that.

@mferrera mferrera merged commit 9408db1 into equinor:main Feb 14, 2024
40 checks passed
@mferrera mferrera deleted the improve-data-reader-error branch February 14, 2024 11:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Improve error-message when no data-reader can be found
3 participants